﻿using MediatR;
using Microsoft.AspNetCore.Mvc;
using RedDragon.Common.Dtos;
using RedDragon.ERP.API.Application.Commands.OutboundOrder;
using T.Common.Domain.Common;

namespace RedDragon.ERP.API.Controllers
{
    /// <summary>
    /// 出库单控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class OutboundOrdersController : ControllerBase
    {
        private readonly IMediator mediator;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="mediator"></param>
        public OutboundOrdersController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 出库单添加
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Result> CreateOutbound(CreateOutboundCommand cmd)
        {
            return await mediator.Send(cmd);
        }
        /// <summary>
        /// 获取出库信息列表查询
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<Result<List<OutbounddDto>>> SearchOutbound([FromQuery] SearchOutboundCommand cmd)
        {
            return await mediator.Send(cmd);
        }
        /// <summary>
        /// 获取出库类型信息查询
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<Result> SearchOutboundType([FromQuery] SearchOutboundTypeCommand cmd)
        {
            return await mediator.Send(cmd);
        }
        /// <summary>
        /// 获取仓库信息查询
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<Result> SearchWarehouse([FromQuery] SearchWarehouseCommand cmd)
        {
            return await mediator.Send(cmd);
        }
        /// <summary>
        /// 根据仓库ID获取仓库信息查询
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<Result> SearchWarehouseID([FromQuery] SearchWarehouseIDCommand cmd)
        {
            return await mediator.Send(cmd);
        }
        /// <summary>
        /// 获取销售信息查询
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<Result> SearchSales([FromQuery] SearchSalesCommand cmd)
        {
            return await mediator.Send(cmd);
        }
        /// <summary>
        /// 根据销售编号获取销售信息
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<Result> SearchSalesId([FromQuery] SearchSalesIdCommand cmd)
        {
            return await mediator.Send(cmd);
        }
        /// <summary>
        /// 根据出货单ID查询出货信息
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<Result<OutbounddDto>> SearchOutboundId([FromQuery] SearchOutboundIdCommand cmd)
        {
            return await mediator.Send(cmd);
        }
        /// <summary>
        /// 出库单修改
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<Result> UpdateOutbound(UpdateOutboundCommand cmd)
        {
            return await mediator.Send(cmd);
        }
    }
}
